import React, { Component } from 'react'
import { connect } from 'dva';
import FormList from '../components/FormItem';

import { KEYS_EDIT } from '../enum'

interface Props {
  dispatch: Function,
  data: {
    id: string,
    buildId: string,
    floorPlan: string
  },
  match: {
    params: {
      id: number
    }
  },
  details: object
}


@connect(({ build_floor }) => ({
  data: build_floor.editDetails
}))
class Update extends Component<Props, any> {

  componentDidMount() {
    const { dispatch, match } = this.props;
    const { params } = match;

    dispatch({
      type: 'build_floor/queryEditInfoById',
      payload: {
        id: params.id,
        keys: KEYS_EDIT
      }
    })
  }

  render() {
    return (
      <>
        <FormList data={this.props.data} key={Date.now()}/>
      </>
    );
  }
}

export default Update;